{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ejercicio: Algoritmo de Euclides\n",
    "\n",
    "Implementar la función `mcd(a,b)` que devuelva el MCD de `a` y `b`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Para implementar la función `mcd` basta meter este código en ella, con una precaución inicial: asegurarse de que $a > b$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def mcd(a, b):\n",
    "    if a < b:\n",
    "        (a, b) = (b, a)\n",
    "    while b:\n",
    "        (a, b) = (b, a % b)\n",
    "    return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "El mcd de 9875863575762721043792310334503671 y 1660415056864053767128165781983 es 23969823740192597\n"
     ]
    }
   ],
   "source": [
    "# Ejemplo de uso\n",
    "a = 9875863575762721043792310334503671\n",
    "b = 1660415056864053767128165781983\n",
    "print(\"El mcd de %s y %s es %s\" % (a, b, mcd(a, b)) )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
